/**
 * 
 */
package br.odb.portalizer;

import br.odb.libscene.Constants;
import br.odb.libscene.Sector;
import br.odb.utils.math.Vec3;

/**
 * @author daniel
 *
 */
public class Hyperplane implements Constants {
	/**
	 * 
	 */
	private byte kind;
	private Vec3 v;
	private Sector generator;

	/////////////////////////////
	
	public int hashCode() {
		return this.toString().hashCode(); 
	}
	
	public boolean equals( Hyperplane another ) {
		
		if ( another == null )
			return false;
		
		if ( !v.equals( another.v ) )
			return false;
		
		if ( kind != another.kind )
			return false;
		
		//the generator sector doesnt matter.
			
		return true;
	}
	
	
	public boolean equals(Object obj) {
	
		return equals( (Hyperplane) obj );
	}
	/////////////////////////////////
	
	public String toString() {
		return "hyperplane: " + v + " kind: " + kind + " generator id: " + generator.getId();
	}
	
	public Hyperplane(byte kind, float n, Sector generator ) {
		
		this.kind = kind;
		this.v = new Vec3( Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE );
		this.generator = generator;
		
		switch ( kind ) {
			case FACE_N:
			case FACE_S:
				v.setZ(n);
				break;
			case FACE_W:
			case FACE_E:
				v.setX(n);
				break;
			case FACE_FLOOR:
			case FACE_CEILING:
				v.setY(n);
				break;
		}
		
	}

	
	/**
	 * 
	 * @return
	 */
	public Vec3 getVector() {
		return v;
	}

	public Sector getGenerator() {
		return generator;
	}

}